@isTest
private class InstallationApplyTriggerTest {
    static testMethod void testMethod1() {

        Province__c pro = TestUtils.createProvince();
        insert pro;

        City__c c = TestUtils.createCity();
        c.Province__c = pro.Id;
        insert c;

        District__c district = TestUtils.createDistrict();
        district.City__c = c.Id;
        insert district;
        
        Account acc = TestUtils.createAccount();
          acc.City__c = c.Id;
        acc.Province__c = pro.Id;
        acc.District__c = district.Id;

        insert acc;

      Dealer__c d = new Dealer__c(
        Name = 'xxxxx',
        Only__c = '13455666'

        );
      insert d;
        Brand__c brand = new Brand__c(
            Name = '迈克生物',
            BrandShortName__c = '迈克生物'
            );
        insert brand;
        //创建产品结构
        ProductStructure__c ps1 = new ProductStructure__c(
        	Classify1__c='生化',
            Classify3__c = '仪器'


        );
      
        insert ps1;
        

        Product__c  CL = new Product__c();
        CL.ProductStructure__c = ps1.Id;
       // ConfigurationList__c CL = new ConfigurationList__c();
        CL.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('NCProduct','Product__c');
        CL.Name='日立7020仪器安装所需';
        CL.CRMBrand__c = brand.Id;
        CL.Model__c = 'xxxx';
        CL.Category0__c = '仪器';

        insert CL;

        TechnicalServicesApplicationForm__c te  = new TechnicalServicesApplicationForm__c();
        te.CustomerName__c = acc.Id;
        te.DealerNEW__c = d.Id;
        te.InstrumentModel__c = cL.Id;
        te.Type__c = '安装';
        te.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('EngineeringEmergencyInstallation', 'TechnicalServicesApplicationForm__c') ;

        System.debug('TechnicalServicesApplicationForm__c==>'+te);
        insert te;



        Case cas=new Case();
        cas.AccountId=acc.Id;
        cas.TechnicalServicesApplicationNum__c = te.Id;
        insert cas;

        WorkOrder__c wo = [select Id from WorkOrder__c where Case__c =:cas.Id];
        // WorkOrder__c wo=new WorkOrder__c();
        // wo.Case__c=cas.Id;
        // wo.Account__c=acc.Id;
        // wo.Status__c='处理中';
        // wo.ManufactureInfo__c=CL.Id;
        // wo.IMEINumber__c = '1245';
        // wo.recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('InstallationOrder','WorkOrder__c');
        // wo.WhetherToMakeASingle__c = '否';
        // insert wo;
        wo.Status__c = '完成';
        update wo ;




    
        InstallationApply__c IA = new InstallationApply__c();
        //IA.Name='安装申请测试1';
        IA.Instrument__c=CL.Id;
        IA.NEWDealer__c = d.Id;
        IA.Hospital__c = acc.Id;
         IA.InstallEstiDate__c = Date.newInstance(2018, 12, 1);
        IA.InstallsNumber__c = 1;
        IA.SupplementOrNot__c = '是';
        Ia.RelatedWorkOrder__c = wo.Id;


        insert IA;

        IA.Status__c = '已批准';
        update IA;


    }
 
    /*static testMethod void testMethod2() {
        Dealer__c d = new Dealer__c(
        Name = 'xxxxx',
        Only__c = '13455666'

        );
      insert d;  
         Account acc = TestUtils.createAccount();
        insert acc;
            //创建产品结构
        ProductStructure__c ps1 = new ProductStructure__c(
        	Classify1__c='生化',
            Classify3__c = '仪器'
        );
        insert ps1;

        Brand__c brand = new Brand__c(
            Name = '迈克生物',
            BrandShortName__c = '迈克生物'
            );
        insert brand;
        Product__c  CL = new Product__c();
        CL.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('NCProduct','Product__c');
        CL.Name='日立7020仪器安装所需';
        CL.ProductStructure__c = ps1.Id;
        CL.Model__c = 'xxxxx';
        CL.CRMBrand__c = brand.Id;
        CL.Category0__c = '仪器';

        insert CL;

         InstallationApply__c IA = new InstallationApply__c();
        IA.Instrument__c=CL.Id;
        IA.NEWDealer__c = d.Id;
        IA.Hospital__c = acc.Id;
        IA.InstallEstiDate__c = Date.newInstance(2018, 12, 1);
        IA.InstallsNumber__c = 1;

        insert IA;

        InstallationApplyWebService.setSObjectShare('InstallationApply__Share', 'Assistant__c', IA.Id, UserInfo.getUserId(), 'Edit');
    }

    */
    
}